iT邦幫忙

2025 iThome 鐵人賽

DAY 10
0

https://ithelp.ithome.com.tw/upload/images/20250924/20177944abmOf0x33Y.jpg

class Solution{//875 O(Nlogm) O(1)
public:
    int minEatingSpeed(vector<int>& a, int h){
        long long L=1, R=*max_element(a.begin(),a.end()); // bounds
        while(L<R){
            long long k=(L+R)>>1, hours=0;// candidate speed
            for(int x:a){ hours+=(x+k-1)/k; if(hours>h) break; } // ceil
            if(hours<=h) R=k; else L=k+1;// shrink
        }
        return (int)L;// minimal k
    }
};

上一篇
Binary Search 5->6 手機發文有難度 & 明天來準備周四簡報囉
系列文
轉職仔之Data Science and ai master後的持續精進技術之路10
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 則留言

0
AndyAWD
iT邦新手 2 級 ‧ 2025-09-24 22:04:51

為什麼有雞排吃...

我要留言

立即登入留言